package com.xmbandu.app.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.xmbandu.app.R;

public class UpdateDialog extends Dialog {
    private Context context;
    private ProgressButton progressButton;
    private TextView tv_update_content;
    public OnDialogClickListener onDialogClickListener;
    public String content;

    public UpdateDialog(@NonNull Context context) {
        super(context);
        this.context = context;

    }

    public UpdateDialog(@NonNull Context context, int themeResId, String content) {
        super(context, themeResId);
        this.context = context;
        this.content = content;
    }

    protected UpdateDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_update, null);
        setContentView(view);
        progressButton = view.findViewById(R.id.progressButton);
        tv_update_content = view.findViewById(R.id.tv_update_content);
        tv_update_content.setText(content + "");
        progressButton.setMaxProgress(100);
        progressButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onDialogClickListener.onYesClick(UpdateDialog.this, progressButton);
            }
        });
    }

    public UpdateDialog setOnDialogClickListener(OnDialogClickListener onDialogClickListener) {
        this.onDialogClickListener = onDialogClickListener;
        return this;

    }
}
